package me.zhengjie.modules.transformer.query.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import me.zhengjie.modules.transformer.query.mapper.RecordMapper;
import me.zhengjie.modules.transformer.query.pojo.FdsRecord;
import me.zhengjie.modules.transformer.query.service.RecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * RecordServiceImpl
 *
 * @author weiruitao
 * @date 2021/12/2
 */
@Service
public class RecordServiceImpl implements RecordService {

    @Autowired
    RecordMapper recordMapper;

    @Override
    public Integer storeRecord(Integer record_id) {
        return recordMapper.insert(new FdsRecord(record_id));
    }

    @Override
    public List<Integer> queryAll() {
        QueryWrapper<FdsRecord> queryWrapper = new QueryWrapper<>();
        queryWrapper.select("record_id");
        List<FdsRecord> fdsRecords = recordMapper.selectList(queryWrapper);
        List<Integer> records = new ArrayList<>();
        for (FdsRecord fdsRecord : fdsRecords) {
            records.add(fdsRecord.getRecordId());
        }
        return records;
    }
}
